using System.Collections.Generic;
using UnityEngine;
namespace DefaultNamespace.Skill
{
    public class SkillUI : MonoBehaviour
    {
        public SkillManager skillManager;
        public GameObject skillSlotPrefab;
        public Transform skillSlotsParent;
        private Dictionary<string, SkillSlot> skillSlots = new Dictionary<string, SkillSlot>();
        private void Start()
        {
            foreach (var skill in skillManager.availableSkills)
            {
                GameObject slotObj = Instantiate(skillSlotPrefab, skillSlotsParent);
                SkillSlot slot = slotObj.GetComponent<SkillSlot>();
                slot.Initialize(skill);
                skillSlots.Add(skill.skillName, slot);
            }
        }
        private void Update()
        {
            foreach (var skill in skillManager.availableSkills)
            {
                if (skillSlots.TryGetValue(skill.skillName, out SkillSlot slot))
                {
                    slot.UpdateCooldown(skill.currentCooldown / skill.cooldown);
                }
            }
        }
    }
}